/**
 * 给指定域名添加cookies
 * @param cname
 * @param value
 * @param url
 */
export function setCookie(cname,value,url) {
  const  exp = new Date()
  exp.setTime(exp.getTime() - 1);
  // date.setSeconds(date.getSeconds() + expire)
  document.cookie = cname+ "="+ escape(value)+"; domain= "+ url +"; expires=" + exp.toGMTString()
}

/**
 * 根据名称获取cookies
 * @param c_name
 * @returns {string}
 */
export function getCookie(c_name){
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') c = c.substring(1);
    if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
  }
  return "";
}

export function delCookie(c_name){
  setCookie(c_name, "", -1)
}